<template>
  <div class="gameSearch">
    <el-form
      :inline="true"
      :model="formData"
      class="demo-form-inline"
      ref="formData"
      style="width: 100%"
    >
      <el-form-item>
        <el-select
          v-model="formData.gameId"
          filterable
          placeholder="输入游戏名搜索"
        >
          <el-option
            v-for="item in options"
            :key="item.id"
            :label="item.gameName"
            :value="item.id"
            style="width: 300px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="formData.status" filterable placeholder="活动状态">
          <el-option
            v-for="item in statusOptions"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            style="width: 130px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="formData.onlineStatus"
          filterable
          placeholder="优惠券状态"
        >
          <el-option
            v-for="item in couponOptions"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            style="width: 130px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="formData.type"
          filterable
          placeholder="活动类型"
        >
          <el-option
            v-for="item in activityOption"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            style="width: 130px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="formData.time"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="margin-top: 6px"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          class="dataSearch"
          @click="dataSearch(formData)"
          >搜索</el-button
        >
      </el-form-item>
      <el-form-item>
        <el-button class="addNewgame" type="primary" @click="addActivity()"
          >添加活动</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getSearchList } from "@/api/gameManage";
export default {
  data() {
    return {
      formData: {
        gameId: "",
        status: "",
        onlineStatus: "",
        time: [],
        type:"",
        page: 1,
        limit: 20,
      },
      options: [],
      couponOptions: [
        {
          id: 0,
          label: "全部",
        },
        {
          id: 1,
          label: "未上线",
        },
        {
          id: 2,
          label: "已上线",
        },
        {
          id: 3,
          label: "已下线",
        },
      ],
      statusOptions: [
        {
          id: 0,
          label: "全部",
        },
        {
          id: 1,
          label: "进行中",
        },
        {
          id: 2,
          label: "未开始",
        },
        {
          id: 3,
          label: "已结束",
        },
      ],
      activityOption: [
        {
          id: 0,
          label: "全部",
        },
        {
          id: 1,
          label: "无门槛活动",
        },
        {
          id: 2,
          label: "满减券活动",
        },
      ],
      loading: false,
    };
  },

  mounted() {
    getSearchList().then((res) => {
      this.options = res.data.list;
    });
  },
  methods: {
    // 查询
    dataSearch() {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.$store.commit("SET_SEARCH", this.formData);
          this.$emit("searchList", this.formData);
        }
      });
    },
    addActivity() {
      this.$emit("showconfirmPopDialog");
    },
  },
};
</script>
<style lang="scss" scoped>
.gameSearch {
  margin-left: 20px;
  width: 52%;
}
.el-form-item {
  margin-bottom: 0;
}
.el-button--primary {
  background-color: #409eff;
  border-color: #409eff;
}
.addNewgame,
.dataSearch {
  padding: 0 15px;
  height: 30px;
  font-size: 13px;
}

.el-select-dropdown__item {
  white-space: normal;
  height: auto;
}
.el-date-editor--daterange.el-input,
.el-date-editor--daterange.el-input__inner,
.el-date-editor--timerange.el-input,
.el-date-editor--timerange.el-input__inner {
  width: 250px;
}
</style>